<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-tarfile.html" />
<link rel="prev" href="module-bz2.html" />
<link rel="parent" href="archiving.html" />
<link rel="next" href="zipfile-objects.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>12.4 zipfile -- Work with ZIP archives</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="12.3.3 one-shot (de)compression"
  href="node303.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="12. data Compression and"
  href="archiving.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="12.4.1 zipfile Objects"
  href="zipfile-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node303.html">12.3.3 One-shot (de)compression</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="archiving.html">12. Data Compression and</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="zipfile-objects.html">12.4.1 ZipFile Objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h1><a name="SECTION0014400000000000000000">
12.4 <tt class="module">zipfile</tt> --
         Work with ZIP archives</a>
</h1>

<p>
<a name="module-zipfile"></a>

<p>

<span class="versionnote">New in version 1.6.</span>

<p>
The ZIP file format is a common archive and compression standard.
This module provides tools to create, read, write, append, and list a
ZIP file.  Any advanced use of this module will require an
understanding of the format, as defined in
<em class="citetitle"><a
 href="http://www.pkware.com/business_and_developers/developer/appnote/"
 title="PKZIP Application Note"
 >PKZIP Application Note</a></em>.

<p>
This module does not currently handle ZIP files which have appended
comments, or multi-disk ZIP files. It can handle ZIP files that use the 
ZIP64 extensions (that is ZIP files that are more than 4 GByte in size).

<p>
The available attributes of this module are:

<p>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-2356' xml:id='l2h-2356' class="exception">error</tt></b></dt>
<dd>
  The error raised for bad ZIP files.
</dd></dl>

<p>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-2357' xml:id='l2h-2357' class="exception">LargeZipFile</tt></b></dt>
<dd>
  The error raised when a ZIP file would require ZIP64 functionality but that
  has not been enabled.
</dd></dl>

<p>
<dl><dt><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-2358' xml:id='l2h-2358' class="class">ZipFile</tt></b>
<dd>
  The class for reading and writing ZIP files.  See
  ``<em class="citetitle"
 >ZipFile Objects</em>'' (section <a href="zipfile-objects.html#zipfile-objects">12.4.1</a>) for
  constructor details.
</dl>

<p>
<dl><dt><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-2359' xml:id='l2h-2359' class="class">PyZipFile</tt></b>
<dd>
  Class for creating ZIP archives containing Python libraries.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-2360' xml:id='l2h-2360' class="class">ZipInfo</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>filename</var><big>[</big><var>, date_time</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Class used to represent information about a member of an archive.
  Instances of this class are returned by the <tt class="method">getinfo()</tt> and
  <tt class="method">infolist()</tt> methods of <tt class="class">ZipFile</tt> objects.  Most users
  of the <tt class="module">zipfile</tt> module will not need to create these, but
  only use those created by this module.
  <var>filename</var> should be the full name of the archive member, and
  <var>date_time</var> should be a tuple containing six fields which
  describe the time of the last modification to the file; the fields
  are described in section <a href="zipinfo-objects.html#zipinfo-objects">12.4.3</a>, ``ZipInfo Objects.''
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2361' xml:id='l2h-2361' class="function">is_zipfile</tt></b>(</nobr></td>
  <td><var>filename</var>)</td></tr></table></dt>
<dd>
  Returns <code>True</code> if <var>filename</var> is a valid ZIP file based on its magic
  number, otherwise returns <code>False</code>.  This module does not currently
  handle ZIP files which have appended comments.
</dl>

<p>
<dl><dt><b><tt id='l2h-2362' xml:id='l2h-2362'>ZIP_STORED</tt></b></dt>
<dd>
  The numeric constant for an uncompressed archive member.
</dd></dl>

<p>
<dl><dt><b><tt id='l2h-2363' xml:id='l2h-2363'>ZIP_DEFLATED</tt></b></dt>
<dd>
  The numeric constant for the usual ZIP compression method.  This
  requires the zlib module.  No other compression methods are
  currently supported.
</dd></dl>

<p>
<div class="seealso">
  <p class="heading">See Also:</p>

  <dl compact="compact" class="seetitle">
    <dt><em class="citetitle"><a href="http://www.pkware.com/business_and_developers/developer/appnote/"
        >PKZIP Application Note</a></em></dt>
    <dd>Documentation on the ZIP file format by
            Phil Katz, the creator of the format and algorithms used.</dd>
  </dl>

<p>
<dl compact="compact" class="seetitle">
    <dt><em class="citetitle"><a href="http://www.info-zip.org/pub/infozip/"
        >Info-ZIP Home Page</a></em></dt>
    <dd>
            Information about the Info-ZIP project's ZIP archive
            programs and development libraries.</dd>
  </dl>
</div>

<p>

<p><br /></p><hr class='online-navigation' />
<div class='online-navigation'>
<!--Table of Child-Links-->
<a name="CHILD_LINKS"><strong>Subsections</strong></a>

<ul class="ChildLinks">
<li><a href="zipfile-objects.html">12.4.1 ZipFile Objects</a>
<li><a href="pyzipfile-objects.html">12.4.2 PyZipFile Objects</a>
<li><a href="zipinfo-objects.html">12.4.3 ZipInfo Objects</a>
</ul>
<!--End of Table of Child-Links-->
</div>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="12.3.3 one-shot (de)compression"
  href="node303.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="12. data Compression and"
  href="archiving.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="12.4.1 zipfile Objects"
  href="zipfile-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node303.html">12.3.3 One-shot (de)compression</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="archiving.html">12. Data Compression and</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="zipfile-objects.html">12.4.1 ZipFile Objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
